﻿using DevExpress.Data;
using DevExpress.XtraEditors;
using DevExpress.XtraGrid;
using DXApplicationTangche.UC.门店出入库.Service;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DXApplicationTangche.UC.门店出入库.UC
{
    public partial class XtraUserControl库存明细 : DevExpress.XtraEditors.XtraUserControl
    {
        private List<String> storeIds = new List<String>();
        public XtraUserControl库存明细()
        {
            InitializeComponent();
            this.storeIds = new List<string>();
            this.storeIds.Add("5");
            this.storeIds.Add("14");
            this.刷新();
        }
        private void 刷新()
        {
            this.gridControl库存明细.DataSource = 出入库Service.getStockDetailByStoreIds(this.storeIds);
            //this.gridView库存明细.GroupSummary.AddRange(new GridSummaryItem[] { new GridGroupSummaryItem(SummaryItemType.Sum, "quantity", null, "(库存数量= {0})"), });
            this.gridView库存明细.ExpandAllGroups();
            this.gridView库存明细.RefreshData();
            //this.gridView库存明细.ExpandAllGroups();
        }
        private void simpleButton刷新_Click(object sender, EventArgs e)
        {
            this.刷新();
        }

        private void simpleButton导出excel_Click(object sender, EventArgs e)
        {
            SaveFileDialog fileDialog = new SaveFileDialog();
            fileDialog.Title = "导出抖音订单";
            fileDialog.Filter = "Excel文件(*.xlsx)|*.xlsx";
            DialogResult dialogResult = fileDialog.ShowDialog(this);
            if (dialogResult == DialogResult.OK)
            {
                DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions();
                this.gridView库存明细.ExportToXlsx(fileDialog.FileName);
                DevExpress.XtraEditors.XtraMessageBox.Show("文件已保存至" + fileDialog.FileName, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }

        private void gridView库存明细_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
        {
            if (e.Column.Name.Equals("gridColumn尺码"))
            {
                if (!String.IsNullOrWhiteSpace(e.DisplayText))
                {
                    try { e.DisplayText = e.DisplayText.Replace("IGS_GROUP_SIZE-", "").Replace("EGS_GROUP_SIZE-", ""); } catch { }
                }
            }
        }

        private void gridView库存详情_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
        {
            if (e.Column.Name.Equals("gridColumn尺码2"))
            {
                if (!String.IsNullOrWhiteSpace(e.DisplayText))
                {
                    try { e.DisplayText = e.DisplayText.Replace("IGS_GROUP_SIZE-", "").Replace("EGS_GROUP_SIZE-", ""); } catch { }
                }
            }
        }
    }
}
